import pygame
import random
import math
class DoubleBullet(pygame.sprite.Sprite):
    def __init__(self,width,height):
        pygame.sprite.Sprite.__init__(self)
        
        self.speed=5
        self.width,self.height=width,height
        self.image=pygame.transform.smoothscale(pygame.image.load('images/get_double_bullet1.png').convert_alpha(),(104,136))
        self.image2=pygame.transform.smoothscale(pygame.image.load('images/get_double_bullet2.png').convert_alpha(),(104,136))
        self.icon_image=pygame.transform.smoothscale(pygame.image.load('images/icon_double_bullet.png').convert_alpha(),(50,50))
        self.rect=self.image.get_rect()
        self.rect.left,self.rect.top=random.randint(0,self.width-self.rect.width),-self.rect.height
        self.mask=pygame.mask.from_surface(self.image)
        self.hitnum=1
    def reset(self):
        self.rect.left,self.rect.top=random.randint(0,self.width-self.rect.width),-self.rect.height
    def move(self):
        if self.rect.top<self.width:
            self.rect.top+=self.speed
        else:
            self.reset()
    
class BigBullet(pygame.sprite.Sprite):
    def __init__(self,width,height):
        pygame.sprite.Sprite.__init__(self)
        
        self.speed=5
        self.width,self.height=width,height
        self.image=pygame.transform.smoothscale(pygame.image.load('images/get_big_bullet1.png').convert_alpha(),(104,136))
        self.image2=pygame.transform.smoothscale(pygame.image.load('images/get_big_bullet2.png').convert_alpha(),(104,136))
        self.icon_image=pygame.transform.smoothscale(pygame.image.load('images/icon_big_bullet.png').convert_alpha(),(50,50))
        self.rect=self.image.get_rect()
        self.rect.left,self.rect.top=random.randint(0,self.width-self.rect.width),-self.rect.height
        self.mask=pygame.mask.from_surface(self.image)
        self.hitnum=3
    def reset(self):
        self.rect.left,self.rect.top=random.randint(0,self.width-self.rect.width),-self.rect.height
    def move(self):
        if self.rect.top<self.width:
            self.rect.top+=self.speed
        else:
            self.reset()

class NarrowPower(pygame.sprite.Sprite):
    def __init__(self,width,height):
        pygame.sprite.Sprite.__init__(self)
        
        self.speed=5
        self.width,self.height=width,height
        self.image=pygame.transform.smoothscale(pygame.image.load('images/get_narrow_power1.png').convert_alpha(),(104,136))
        self.image2=pygame.transform.smoothscale(pygame.image.load('images/get_narrow_power2.png').convert_alpha(),(104,136))
        self.icon_image=pygame.transform.smoothscale(pygame.image.load('images/icon_narrow_power.png').convert_alpha(),(50,50))
        self.rect=self.image.get_rect()
        self.rect.left,self.rect.top=random.randint(0,self.width-self.rect.width),-self.rect.height
        self.mask=pygame.mask.from_surface(self.image)
    def reset(self):
        self.rect.left,self.rect.top=random.randint(0,self.width-self.rect.width),-self.rect.height
    def move(self):
        if self.rect.top<self.width:
            self.rect.top+=self.speed
        else:
            self.reset()
            
class Missile(pygame.sprite.Sprite):
    def __init__(self,width,height):
        pygame.sprite.Sprite.__init__(self)
        
        self.speed=5
        self.width,self.height=width,height
        self.image=pygame.transform.smoothscale(pygame.image.load('images/get_missile1.png').convert_alpha(),(104,136))
        self.image2=pygame.transform.smoothscale(pygame.image.load('images/get_missile2.png').convert_alpha(),(104,136))
        self.icon_image=pygame.transform.smoothscale(pygame.image.load('images/icon_missile.png').convert_alpha(),(50,50))
        self.rect=self.image.get_rect()
        self.rect.left,self.rect.top=random.randint(0,self.width-self.rect.width),-self.rect.height
        self.mask=pygame.mask.from_surface(self.image)
        self.num=10
    def reset(self):
        self.rect.left,self.rect.top=random.randint(0,self.width-self.rect.width),-self.rect.height
    def move(self):
        if self.rect.top<self.width:
            self.rect.top+=self.speed
        else:
            self.reset()

class SendMissile(pygame.sprite.Sprite):
    def __init__(self,width,height,pos,angle):
        pygame.sprite.Sprite.__init__(self)
        
        self.speed=12
        self.width,self.height=width,height
        self.image=pygame.transform.rotate(pygame.image.load('images/missile1.png').convert_alpha(),270-angle*57.29)
        self.image2=pygame.transform.rotate(pygame.image.load('images/missile2.png').convert_alpha(),270-angle*57.29)
        self.boom_image=pygame.transform.rotate(pygame.image.load('images/boom_missile.png').convert_alpha(),270-angle*57.29)
        self.rect=self.image.get_rect()
        self.rect.left,self.rect.top=pos[0],pos[1]
        self.mask=pygame.mask.from_surface(self.image)
        self.angle=angle
    def move(self):
        self.rect.left+=self.speed*math.cos(self.angle)
        self.rect.top+=self.speed*math.sin(self.angle)

